package com.lehe.wxpay;

import com.lehe.common.Contants;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * 类的相关描述
 *
 * @author 王丹
 * @since 2017-09-22
 */
public class WXPayConfigImpl implements WXPayConfig {

    private byte[] certData;

    public WXPayConfigImpl(){
        /*try{
            String certPath = "/path/to/apiclient_cert.p12";
            File file = new File(certPath);
            InputStream certStream = new FileInputStream(file);
            this.certData = new byte[(int) file.length()];
            certStream.read(this.certData);
            certStream.close();
        }catch (Exception e){
            e.printStackTrace();
        }*/
    }

    @Override
    public String getAppID() {
        return Contants.APP_ID;
    }

    @Override
    public String getMchID() {
        return Contants.PAY_MCH_ID;
    }

    @Override
    public String getKey() {
        return Contants.PAY_KEY;
    }

    @Override
    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    @Override
    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return 10000;
    }
}
